package day05;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Demo03 {
    public static void main(String[] args) {
        /*
         * 单线程线程池
         */
        ExecutorService pool =
                Executors.newSingleThreadExecutor();
        pool.execute(()-> System.out.println(Thread.currentThread()));
        pool.execute(()-> System.out.println(Thread.currentThread()));
        pool.execute(()-> System.out.println(Thread.currentThread()));
        pool.execute(()-> System.out.println(Thread.currentThread()));
        pool.execute(()-> System.out.println(Thread.currentThread()));
        pool.execute(()-> {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread());
        });
        pool.shutdown();
    }
}
